using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Text;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected string TopStories()
    {


        SqlCommand sp = new SqlCommand("cm_getTopNews", conn);
        sp.CommandType = CommandType.StoredProcedure;
        //sp.Parameters.AddWithValue("@BUp", 100);
        conn.Open();
        SqlDataReader rdr = sp.ExecuteReader();

        StringBuilder topstories = new StringBuilder();

        while (rdr.Read())
        {
            string ev_text = rdr.GetString(3).Substring(0, rdr.GetString(3).ToLower().IndexOf("<", 100));

            string topstory = String.Format("<div id=\"topnews\"><h3>{0}</h3><div id=\"topnewstime\">{1}</div>{2}<br />[<a href=\"/{3}.aspx\">read more</a>]<br /><br /></div>", rdr.GetString(1), rdr.GetDateTime(2), ev_text, rdr.GetInt32(0));

            topstories.Append(topstory);
        }

        rdr.Close();
        conn.Close();

        return topstories.ToString();
    }

    //Disable viewstate
    protected override void SavePageStateToPersistenceMedium(object viewState)
    {
       
    }
    protected override object LoadPageStateFromPersistenceMedium()
    {
        return null;
    }
}
